package cn.lili.modules.system.entity.dto;

import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.system.entity.dos.LiAuthSpace;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.io.Serial;

/**
 * 授权空间分页查询参数
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AuthSpaceSearchParams extends PageVO {
    @Serial
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "空间名称")
    private String name;

    @ApiModelProperty(value = "空间编号")
    private String code;

    public LambdaQueryWrapper<LiAuthSpace> queryWrapper(){
        return new LambdaQueryWrapper<LiAuthSpace>()
                .like(StringUtils.isNotEmpty(name),LiAuthSpace::getName,name)
                .eq(StringUtils.isNotEmpty(code),LiAuthSpace::getCode,code)
                .orderByDesc(LiAuthSpace::getCreateTime);
    }
}
